module.exports = function ($) {


		$('#upload_showImg').click(function(){
			$.ajax({
				url: '/upload',
				type: 'POST',
				cache: false,
				data: new FormData($('#showImgForm')[0]),
				processData: false,
				contentType: false
			}).done(function(res) {
				var result = JSON.parse(res)
				console.log(result)
				for(var i =0; i<result.length; i++){
					//console.log(result[i])
					$('#preview_showImg').append('<div class="preview_hide"><img src="http://localhost:4000/upload/'+ result[i] +'" width="300"><button class="deleteImg" >删除</button></div>')
					$('.deleteImg').click(function(){
						$(this).parent().remove();
					})
				}
			}).fail(function(res) {});
		})
		$('#upload_coverImg').click(function(){
			$.ajax({
				url: '/upload',
				type: 'POST',
				cache: false,
				data: new FormData($('#coverImgForm')[0]),
				processData: false,
				contentType: false
			}).done(function(res) {
				var result = JSON.parse(res)
				console.log(result)
				for(var i =0; i<result.length; i++){
					console.log(result[i])
					$('#preview_coverImg').append('<div class="preview_hide"><img src="http://localhost:4000/upload/'+ result[i] +'" width="300"><button class="deleteImg" >删除</button></div>')
					$('.deleteImg').click(function(){
						$(this).parent().remove();
					})
				}
			}).fail(function(res) {});
		})
		$('#upload_video').click(function(){
			$.ajax({
				url: '/upload',
				type: 'POST',
				cache: false,
				data: new FormData($('#videoForm')[0]),
				processData: false,
				contentType: false
			}).done(function(res) {
				var result = JSON.parse(res)
				console.log(result)
				for(var i =0; i<result.length; i++){
					console.log(result[i])
					$('#preview_video').append('<div class="preview_hide"><img src="http://localhost:4000/upload/'+ result[i] +'" width="300"><button class="deleteImg" >删除</button></div>')
					$('.deleteImg').click(function(){
						$(this).parent().remove();
					})
				}
			}).fail(function(res) {});
		});
};